/**********************************************************************************
**
** Copyright (C) 2009 Jostein Bratlie
** Contact: jostein.bratlie@gmail.com | http://bratlie.info | http://episteme.hin.no
**
** This file is part of GMQtExt, a GMlib and Qt extension library
**
** GMQtExt is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** GMQtExt is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with GMQtExt.  If not, see <http://www.gnu.org/licenses/>.
**
**********************************************************************************/

#ifndef CREATEOBJECTWIDGET_H
#define CREATEOBJECTWIDGET_H


// Qt
#include <QWidget>
#include <QModelIndex>

class QTreeWidget;
class QTreeWidgetItem;

// GMlib
namespace GMlib {

  class SceneObject;

  template <typename T> class PCircle;

  template <typename T> class PSphere;
  template <typename T> class PTorus;
}


namespace GMQtExt {

  class CreateObjectWidget : public QWidget {
    Q_OBJECT
  public:
    CreateObjectWidget( QWidget* parent = 0x0 );

    void                clearSelection();

  public slots:
    bool                insertObject();

  protected:
    QTreeWidgetItem*    createGroup( const QString& name, QTreeWidgetItem* group = 0x0 );
    QTreeWidgetItem*    createItem( const QString& name, const QString& identifier, QTreeWidgetItem* group = 0x0 );
    QString             getItemId( QTreeWidgetItem* item ) const;

  private:
    static GMlib::PCircle<float>
                        *_prototype_pcircle_float;

    static GMlib::PSphere<float>
                        *_prototype_psphere_float;
    static GMlib::PTorus<float>
                        *_prototype_ptorus_float;

    QMap<QTreeWidgetItem*,QString>
                        _item_id;
    QTreeWidget         *_item_tree;

    void                _populateItemTree();

  private slots:
    void                _slotObjectSelected( QTreeWidgetItem*, int );

  signals:
    void                signCreateObject( GMlib::SceneObject** obj );
    void                signInsertObject( GMlib::SceneObject* obj );
    void                signObjectSelected( GMlib::SceneObject* obj );
  };

} // END namespace GMQtExt

#endif // CREATEOBJECTWIDGET_H
